const config = {
    
    building : {
        sX : 221,
        sY : 662,
        storehouses : [
            {
                name:"c1",
                x:8.5,y:1,z:29,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:59,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:89,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:129,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:169,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:209,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:249,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:289,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:349,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:59,y:1,z:349,
                sx:49,sy:25, sz:18.5,
            },

            {
                name:"c_1_1",
                x:8.5,y:1,z:379,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:59,y:1,z:379,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:429,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:59,y:1,z:429,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:8.5,y:1,z:469,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:59,y:1,z:469,
                sx:49,sy:25, sz:18.5,
            },


            {
                name:"c_1_1",
                x:8.5,y:1,z:509,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:59,y:1,z:509,
                sx:49,sy:25, sz:18.5,
            },

            {
                name:"c_1_1",
                x:8.5,y:1,z:549,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:59,y:1,z:549,
                sx:49,sy:25, sz:18.5,
            },

            {
                name:"c_1_1",
                x:8.5,y:1,z:589,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:59,y:1,z:589,
                sx:49,sy:25, sz:18.5,
            },


            // 右边
            {
                name:"c_1_1",
                x:123.5 ,y:1,z:29,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5 ,y:1,z:59,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:89,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:129,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:169,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:209,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:249,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:289,
                sx:98.5,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:349,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:174,y:1,z:349,
                sx:49,sy:25, sz:18.5,
            },

            {
                name:"c_1_1",
                x:123.5,y:1,z:379,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:174,y:1,z:379,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:429,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:174,y:1,z:429,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:123.5,y:1,z:469,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:174,y:1,z:469,
                sx:49,sy:25, sz:18.5,
            },


            {
                name:"c_1_1",
                x:123.5,y:1,z:509,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:174,y:1,z:509,
                sx:49,sy:25, sz:18.5,
            },

            {
                name:"c_1_1",
                x:123.5,y:1,z:549,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:174,y:1,z:549,
                sx:49,sy:25, sz:18.5,
            },

            {
                name:"c_1_1",
                x:123.5,y:1,z:589,
                sx:49,sy:25, sz:18.5,
            },
            {
                name:"c_1_1",
                x:174,y:1,z:589,
                sx:49,sy:25, sz:18.5,
            },
        ]
    }
}

export { config };





productData.forEach(product => {
    var buildType = product.buildType;
    var stackType = product.stackType;
    var name = buildType+"_"+stackType;
    var unitNum = product.unitNum;

    console.log(name);
    var aaa = sceneGroup.getObjectByName(name);
    console.log(aaa);

    //根据编号获取 层级  对应  不同摆放类型
    var pos_type = "pos_type2";
    switch(stackType)
    {
        case "s1":
            pos_type = "pos_type1";
            break;
        case "s2":
            pos_type = "pos_type2";
            break;

        case "s3":
            pos_type = "pos_type3";
            break;
    }
    var product_unit = config.unit[pos_type][unitNum - 1];
    sceneGroup.children.forEach(storehouse => {
        if(buildType == storehouse.name){
            var stacks = storehouse.children;
            stacks.forEach( stack => {
                if(name == stack.name)
                {
                    var product = createProduct(config.unit.sX,config.unit.sH,config.unit.sY,product_unit.rx,product_unit.ry,product_unit.rz);
                    // 25 来源于厂房的高度
                    // var pos = new THREE.Vector3(
                    //     product_unit.x - config.unit.sX / 2 + config.stack.sY_half,
                    //     product_unit.y - 25 / 2 + config.unit.sH / 2,
                    //     product_unit.z + config.unit.sY / 2);
                    var pos = new THREE.Vector3(
                        product_unit.x * config.unit.sX + config.unit.sX / 2 -  config.stack.sX_half,
                        product_unit.y + config.unit.sH / 2 - 25 / 2,
                        - product_unit.z * config.unit.sX - config.unit.sY / 2 + config.stack.sY_half - product_unit.z * config.unit.z_offset);



                        if(product_unit.ry != 0) //不等于0 就是旋转90度了，需要跳动x坐标
                        {

                            switch(pos_type)
                            {
                                case "pos_type1":
                                    pos.x -= (config.unit.sX -  config.unit.sY) / 1.5;
                                    pos.z -= (config.unit.sY -  config.unit.sX) / 6;
                                    break;
                                case "pos_type2":
                                    pos.x += (config.unit.sY -  config.unit.sX) / 2;
                                    pos.z =  - product_unit.z * (config.unit.sY -  config.unit.sX) - config.unit.sX / 2 + config.stack.sY_half - product_unit.z * config.unit.z_offset;
                                    break;
                                case "pos_type3":
                                    pos.z =  - product_unit.z * (config.unit.sY -  config.unit.sX) - config.unit.sX / 2 + config.stack.sY_half - product_unit.z * config.unit.z_offset;
                                    break;
                            }
                          
                        }




                    product.position.copy(pos);
                    stack.add(product);
                    // console.log(product);
                    return;
                }
            })

        }
    })
});
    